<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>移动端响应式布局</title>
    <style>
        /* html{
            font-size: 20px;
        } */
        .box-px{
            width: 300px;
            height: 100px;
            background-color: blueviolet;
            margin-bottom: 50px;
        }
        .box-rem{
            width: 5rem;
            height: 3rem;
            background-color: aqua;
        }
    </style>
</head>
<body>
    <div class="box-px"></div>
    <div class="box-rem"></div>
    <script>
        function resetHtmlFontSize(){
            document.documentElement.style.fontSize=screen.width/10+'px';
        }
        resetHtmlFontSize();
        window.onresize=resetHtmlFontSize;
    </script>
</body>
</html>